package kr.or.kosta.otr.persistence.interestcompany;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.annotation.Resource;

import kr.or.kosta.otr.vo.InterestCompanyVO;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
@Repository("InterestCompanyDao")

public class InterestCompanyDaoImpl implements InterestCompanyDao{
	@Resource(name="sqlMapClient")
	private SqlMapClient sqlMapClient;
	
	
	
	@Override
	public void addInterestCompany(InterestCompanyVO interestCompanyVO)
			throws SQLException {
		sqlMapClient.insert("InterestCompany.addInterestCompany",interestCompanyVO);
		
	}

	@Override
	public void deleteInterestCompany(int interestCompanyId)
			throws SQLException {
		sqlMapClient.delete("InterestCompany.deleteInterestCompany", interestCompanyId);
	}

	@Override
	public ArrayList<InterestCompanyVO> getAllInterestCompany(String userId)
			throws SQLException {
		return (ArrayList<InterestCompanyVO>)sqlMapClient.queryForList("InterestCompany.getAllInterestCompany", userId);
	}

	@Override
	public boolean checkInterestCompany(HashMap<String, Object> map) throws SQLException {
		int i = (int)sqlMapClient.queryForObject("InterestCompany.checkInterestCompany", map);		
		if(i != 0)
			return false;
		else 
			return true;
	}

	@Override
	public ArrayList<InterestCompanyVO> getAllInterestCompanyList(int companyId)
			throws SQLException {
		
		return (ArrayList<InterestCompanyVO>) sqlMapClient.queryForList("InterestCompany.getAllInterestCompanyList",companyId);
	}

	@Override
	public int myInterestCompany(String userId) throws SQLException {
		// TODO Auto-generated method stub
		return (int) sqlMapClient.queryForObject("InterestCompany.myInterestCompany", userId);
	}
	
}
